<template>
  <div class="collapse">
    <div class="title">
      <div><slot name="title"></slot></div>
      <div v-if="isShow">
        <i
          class="iconfont icon-jianhao"
          style="font-weight: 700"
          @click="change"
        ></i>
      </div>
      <div v-else>
        <i
          class="iconfont icon-jiahao"
          style="font-weight: 700"
          @click="change"
        ></i>
      </div>
    </div>
    <div class="content" v-if="isShow" :style="{ opacity: isShow ? 1 : 0 }">
      <slot name="content"></slot>
    </div>
  </div>
</template>
<script>
export default {
  name: 'SCollapse',
  data () {
    return {
      isShow: false
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    change () {
      this.isShow = !this.isShow
    }
  }
}
</script>
<style lang='less'  scoped>
.collapse {
  margin: 20px;
  padding: 20px;
  height: auto;
  background-color: #fff;
  border-radius: 10px;
  transition: all 0.5s;
  .title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 550;
    color: #2a2929;
    .iconfont {
      color: #ef4f3f;
      font-size: 20px;
    }
  }
  .content {
    margin-top: 20px;
  }
}
</style>
